package com.crm.biz.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.crm.model.BizContractDetail;
import com.crm.service.BizContractDetailService;
import com.crm.util.JsonUtil;
import com.crm.util.ResponseUtil;
import com.github.pagehelper.Page;

@Controller
@RequestMapping("/bizContractDetail")
public class BizContractDetailController {
	@Autowired
	private BizContractDetailService bizContractDetailService;
	@RequestMapping("/index")
	public String index(String partnerId){
		return "configuration/contractManage";
	}

	@RequestMapping("/getAll")
	@ResponseBody
	public Map<String, Object> getAll(Page<BizContractDetail> page, BizContractDetail t){
		Map<String, Object> map = new HashMap<>();
		Page<BizContractDetail> list = (Page<BizContractDetail>) bizContractDetailService.selectAll(page, t);
		
		map.put("list", list);
		map.put("status", "success");
		map.put("msg", "查询成功！");
		
		return map;
	}
	
	@RequestMapping("/addNewRecord")
	@ResponseBody
	public Map<String, Object> addNewRecord(BizContractDetail record){
		
		Map<String, Object> map = new HashMap<>();
		
		bizContractDetailService.insert(record);
		
		map.put("status", "success");
		map.put("msg", "新增成功！");
		
		return map;
	}
	
	@RequestMapping("/updateRecord")
	@ResponseBody
	public Map<String, Object> updateRecord(BizContractDetail record){
		
		Map<String, Object> map = new HashMap<>();
		
		bizContractDetailService.updateByPrimaryKey(record);
		
		map.put("status", "success");
		map.put("msg", "修改成功！");
		
		return map;
	}
	
	@RequestMapping("/load")
	@ResponseBody
	public void load(HttpServletResponse response,HttpServletRequest request, Page<BizContractDetail> page, BizContractDetail t){
		Page<BizContractDetail> list = (Page<BizContractDetail>) bizContractDetailService.selectAll(page, t);
		ResponseUtil.resultPage(response,request,list);
	}
	
	/**
	 * 
	 * @Description : 获取专业
	 * @author zealot
	 * @param @param response
	 * @param @param t
	 * @return void
	 * @version 创建时间 : 2016年12月27日 上午10:02:38
	 * @thorws
	 */
	@RequestMapping("/ajaxLoadDetail")
	@ResponseBody
	public void ajaxLoadDetail(HttpServletResponse response,BizContractDetail t){
		ResponseUtil.result(response, JsonUtil.toJsonStr(bizContractDetailService.selectByUs(t)));
	}
	
	/**
	 * 
	 * @Description : 获取院校
	 * @author zealot
	 * @param @param response
	 * @param @param t
	 * @return void
	 * @version 创建时间 : 2016年12月27日 上午10:02:58
	 * @thorws
	 */
	@RequestMapping("/ajaxLoadSchool")
	@ResponseBody
	public void ajaxLoadSchool(HttpServletResponse response,BizContractDetail t){
		ResponseUtil.result(response, JsonUtil.toJsonStr(bizContractDetailService.selectByUsForSchool(t)));
	}
}
